package com.wencai.test;

import com.wencai.bean.IndexStocks;
import com.wencai.util.CombineUtils;
import com.wencai.util.ExportUtils;
import com.wencai.util.IOUtils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author wangpan
 * @date 2023/5/9
 */
public class DataRearrange {
    private static String dir = "D:\\Users\\Administrator\\Desktop\\记录\\";

    public static void main(String[] args) throws IOException {
        File f = new File(dir);
        String[] list = f.list();
        List<IndexStocks> indexStockList = new ArrayList<>();
        for (String child : list) {
            if (child.matches("\\d+\\.txt")) {
                String date = child.replaceAll("(\\d+)\\D+", "$1");
                List<String> dataList = IOUtils.readFromFile(dir + child);
                indexStockList.addAll(CombineUtils.convertData(dataList, date));
            }
        }
        ExportUtils.exportIndexStocks(indexStockList, IndexStocks.class, dir+"统计.xlsx");
    }
}
